-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP update Stan to lvl6 #1
base: develop
Are you sure you want to change the base?
Conversation
8b1baff
to
c5870e3
Compare
/** | ||
* @return array<string,mixed> | ||
* | ||
* @psalm-suppress PossiblyUnusedMethod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mplesa1 this method is used inside the project, how come Psalm recognizes it as unused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used inside tests
* | ||
* @throws JsonApiEncodingException | ||
* | ||
* @psalm-suppress PossiblyUnusedMethod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used inside tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though it's used, Psalm recognizes it as unused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the annotation because it's also used inside PhpArrayToRelationshipCollectionEncoder. But yes, if it's only used inside some test we need annotation.
src/Definition/Encoding/PhpArrayToRelationshipCollectionEncoderInterface.php
Outdated
Show resolved
Hide resolved
src/Definition/Exception/Request/UnsupportedFilterAttributeGivenException.php
Outdated
Show resolved
Hide resolved
src/Definition/Model/Request/CreateResourceRequestInterface.php
Outdated
Show resolved
Hide resolved
src/Definition/Model/Request/UpdateResourceRequestInterface.php
Outdated
Show resolved
Hide resolved
src/Implementation/Encoding/PhpArrayToAttributeCollectionEncoder.php
Outdated
Show resolved
Hide resolved
@@ -6,7 +6,9 @@ | |||
|
|||
use Undabot\JsonApi\Definition\Model\Resource\ResourceInterface; | |||
|
|||
/** @psalm-suppress UnusedClass */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Psalm documentation says the following:
If this class is used and part of the public API, annotate it with @psalm-api.
I believe we should check all of the classes that are used as part of json-api-symfony and mark them with @psalm-api
instead of suppressing the error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, I replace it
$rawMeta = $resource['meta'] ?? null; | ||
$rawLink = $resource['links']['self'] ?? null; | ||
|
||
$rawAttributes = $this->assertStringKeyArray($resource['attributes'] ?? []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about adding a string $key
to this method, resulting in the coalescing operator being moved to the assertStringKeyArray
method to avoid doing it outside on each call to the method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree, good catch, I refactored both assertStringKeyArray and assertStringKeyArrayNested
private function assertStringKeyArray(mixed $array): array | ||
{ | ||
if (!is_array($array)) { | ||
throw new \InvalidArgumentException("Parameter is not array."); | ||
} | ||
foreach ($array as $key) { | ||
if (!is_string($key)) { | ||
throw new \InvalidArgumentException("Array key must be a string."); | ||
} | ||
} | ||
|
||
return $array; | ||
|
||
} | ||
|
||
/** | ||
* | ||
* @param mixed $array | ||
* @return array<string, array<string, mixed>> | ||
*/ | ||
function assertStringKeyArrayNested(mixed $array): array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These methods could be moved to some sort of a utility class if we're going to need them in more places?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I move them to the existing abstract class ArrayUtil
/** | ||
* @implements IteratorAggregate<int,Sort> | ||
*/ | ||
class SortSet implements \IteratorAggregate | ||
{ | ||
/** @var Sort[] */ | ||
private $sorts; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
class AttributeCollection implements AttributeCollectionInterface | ||
{ | ||
/** @var Attribute[] */ | ||
/** @var AttributeInterface[] */ | ||
private $attributes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
use Undabot\JsonApi\Definition\Model\Resource\Relationship\RelationshipCollectionInterface; | ||
use Undabot\JsonApi\Definition\Model\Resource\Relationship\RelationshipInterface; | ||
|
||
class RelationshipCollection implements RelationshipCollectionInterface | ||
{ | ||
/** @var array */ | ||
/** @var RelationshipInterface[] */ | ||
private $relationships = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
// $message = sprintf('ResourceIdentifierInterface expected, %s given', \get_class($resourceIdentifier)); | ||
// | ||
// throw new InvalidArgumentException($message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, @KondukterCRO did those changes in this branch d05ac8b#diff-390909c32070ee11ae2baba70ca5c9e766a3b2bf1a3a2297dd63ddde7a79f4db Pena, do you have some information?
// $message = sprintf('ResourceIdentifierInterface expected, %s given', \get_class($resourceIdentifier)); | ||
// | ||
// throw new InvalidArgumentException($message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question as before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KondukterCRO same question as before
…nEncoderInterface
…th adding key param and handle null
@@ -8,5 +8,8 @@ | |||
|
|||
interface LinkToPhpArrayEncoderInterface | |||
{ | |||
/** | |||
* @return null|array<string,mixed>|string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😱
Description:
Updating PHPStan to lvl6